package com.lzlclass.conf;

import com.lzlclass.intercepter.CosInterceptor;
import com.lzlclass.intercepter.LoginHandleInterceptor;
import com.lzlclass.util.MylocaleResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//该类用来扩展MVC 的功能

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns 配置拦截的URI /** 拦截所有
        // excludePathPatterns 排除掉一部分拦截的规则、
        registry.addInterceptor(new CosInterceptor()).addPathPatterns("/**").order(1);
        registry.addInterceptor(new LoginHandleInterceptor()).addPathPatterns("/**").excludePathPatterns("/css/*","/images/*").order(1);

    }

    //  自定义国际化组件
    @Bean
    public LocaleResolver localeResolver(){
        return new MylocaleResolver();
    }
}